package ldh.im.base.handler;

import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import ldh.im.base.handler.service.HandlerService;
import ldh.im.dto.DtoData;
import ldh.im.dto.base.Req;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@ChannelHandler.Sharable
public class ToHandler extends SimpleChannelInboundHandler<DtoData> {

    private static final Logger LOGGER = LoggerFactory.getLogger(ToHandler.class);

    private HandlerService handlerService;

    public ToHandler(HandlerService handlerService) {
        this.handlerService = handlerService;
    }

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, DtoData req) throws Exception {
        handlerService.handle(ctx.channel(), req);
    }

}
